import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_shop_z/pages/details_page/detail_web.dart';

//详情,评论
class DetailsTabBar extends StatefulWidget {
  int commodityId;
  DetailsTabBar(this.commodityId);
  _DetailsTabBarState createState() => _DetailsTabBarState(this.commodityId);
}

class _DetailsTabBarState extends State<DetailsTabBar> {
  bool isLeft = true;
  int commodityId;
  _DetailsTabBarState(this.commodityId);

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(top: 15),
      child: Column(
        children: <Widget>[
          Row(
            children: <Widget>[
              _myTabBarLeft(),
              _myTabBarRight(),
            ],
          ),
          DetailsWeb(isLeft, commodityId),
        ],
      ),
    );
  }

  Widget _myTabBarLeft() {
    return InkWell(
      onTap: () {
        setState(() {
          isLeft = true;
        });
      },
      child: Container(
        padding: EdgeInsets.all(10),
        alignment: Alignment.center,
        width: ScreenUtil().setWidth(375),
        decoration: BoxDecoration(
          color: Colors.white,
          border: Border(
            bottom: BorderSide(
              width: 1.0,
              color: isLeft ? Colors.purple : Colors.black12,
            ),
          ),
        ),
        child: Text(
          '详细',
          style: TextStyle(color: isLeft ? Colors.purple : Colors.black),
        ),
      ),
    );
  }

  Widget _myTabBarRight() {
    return InkWell(
      onTap: () {
        setState(() {
          isLeft = false;
        });
      },
      child: Container(
        padding: EdgeInsets.all(10),
        alignment: Alignment.center,
        width: ScreenUtil().setWidth(375),
        decoration: BoxDecoration(
          color: Colors.white,
          border: Border(
            bottom: BorderSide(
                width: 1, color: isLeft ? Colors.black12 : Colors.purple),
          ),
        ),
        child: Text(
          '评论',
          style: TextStyle(
            color: isLeft ? Colors.black : Colors.purple,
          ),
        ),
      ),
    );
  }
}
